package cn.herlioner.service;

import java.util.List;

import org.junit.Test;

import cn.herlioner.dao.impl.AdministratorDAOImpl;
import cn.herlioner.dao.impl.PermissionsDAOImpl;
import cn.herlioner.dao.impl.StudentDAOImpl;
import cn.herlioner.dao.impl.TeacherDAOImpl;
import cn.herlioner.pojo.Administrator;
import cn.herlioner.pojo.Permissions;
import cn.herlioner.pojo.Student;
import cn.herlioner.pojo.Teacher;

public class LoginServiceImpl implements LoginService {
	
/**
 * 验证登录账号权限
 */
@Test
public Integer login(Long Num ,String Pad) {
		Administrator administrator = new Administrator();
		AdministratorDAOImpl adminstratorDAO = new AdministratorDAOImpl();
		
		Teacher teacher = new Teacher();
		TeacherDAOImpl teacherDAO = new TeacherDAOImpl();
		
		Student student = new Student();
		StudentDAOImpl studentDAO = new StudentDAOImpl();
		
		student.setStunum((long) 0);
		student.setStupad(null);
		System.out.println("来到了登录验证");
		System.out.println(Num+"asda"+Pad);
		if(Num<99999){
			//管理员权限
			administrator = adminstratorDAO.get(Num);
			if(administrator != null && administrator.getAdpad().equals(Pad)){
				return 1;
			}
			//管理员登陆失败
			System.out.println("1");
			return 0;
		}else if(Num<999999 && Num>99999){
			//老师权限
			teacher = teacherDAO.get(Num);
			if(teacher != null && teacher.getTeapad().equals(Pad)){
				return 2;
			}
			System.out.println("2");
			return 0;
		}else{
			//学生权限
			student = studentDAO.get(Num);
			if(student != null && student.getStupad().equals(Pad)){
				return 3;
			}
			System.out.println("3");
			return 0;
		}
	}




}
